
const tokenName = 'userTokenName'
const historyName = 'historyName'
/**
 * 存user的token
 * @param {Object} tokenObj
 */
export function setToken(tokenObj) {
  localStorage.setItem(tokenName, JSON.stringify(tokenObj))
}
/**
 * 取user的token
 * @returns getToken
 */
export function getToken() {
  return JSON.parse(localStorage.getItem(tokenName)) || {}
}
/**
 * 移除user的token
 */
export function removeToken() {
  localStorage.removeItem(tokenName)
}

/**
 * 存储历史记录
 * @param {*} historyKeyword
 */
export function setHistory(historyKeyword) {
  localStorage.setItem(historyName, JSON.stringify(historyKeyword))
}
/**
 * 取出历史记录
 * @returns
 */
export function getHistory() {
  return JSON.parse(localStorage.getItem(historyName)) || []
}
